package com.deke.course.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.deke.course.service.EduCourseService;
import com.deke.course.service.EduSubjectService;
import com.deke.course.vo.CourseVo;
import com.deke.course.vo.QianSubjectVo;
import com.deke.entity.EduCourse;
import com.deke.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

/**
 * @version 1.0
 * @Author :LiM
 * @Date :2022/12/9 23:41
 */
@RestController
@RequestMapping("/core/course")
@Api(tags = "课程列表接口类")
public class CourseListController {
    @Autowired
    private EduSubjectService subjectService;
    @Autowired
    private EduCourseService courseService;
    @ApiOperation(value = "根据条件分页查询课程列表信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageCurrent",value = "当前页码"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示的条数"),
    })
    @PostMapping("/findCourse/{Current}/{pageSize}")
    public Result<IPage<EduCourse>> findsubject(@RequestBody CourseVo courseVo,
                                                @PathVariable(required = true) Integer Current,
                                                @PathVariable(required = true) Integer pageSize
    ){
        return courseService.findByConditionPage(courseVo,Current,pageSize);
    }

    @PostMapping("/changeStatus")
    public Result changeStatusId(@RequestBody Map map){
        return courseService.changeStatus(map);
    }
    @PostMapping("/updateCourse")
    public Result updateCourse(@RequestBody CourseVo courseVo){
        return courseService.updateCourse(courseVo);
    }
    
    /**
     * @create by: Username 刘亦辰 
     * @description: 前台 课程中心 
     * @create time: 2022/12/21 21:36
     * @param null 
     * @return :  
     **/
    @PostMapping("/fontFindCourse/{pageCurrent}/{pageSize}")
    public Result fontFindCourse(@PathVariable Integer pageCurrent, @PathVariable Integer pageSize, @RequestBody QianSubjectVo qianSubjectVo){
        return courseService.fontFindCourse(pageCurrent,pageSize,qianSubjectVo);
    }
    
    /**
     * @create by: Username 刘亦辰 
     * @description: 前台 拿到全部的分类 
     * @create time: 2022/12/21 21:25
     * @param null 
     * @return :  
     **/
    @PostMapping("getAllMenu")
    public Result getAllMenu(){
        return subjectService.getAllMenu();
    }

    /**
     * 根据课程id查询对应课程id以及教师信息
     * @param
     * @return
     */
    @PostMapping("/queryAllCourseAndTeacherName/{id}")
    public Result queryCourseTeacherByCourseId(@PathVariable("id") String id){
        return courseService.queryCourseAndTeacherByCourseId(id);
    }
}
